﻿using ExcelFileQueryTool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UnitTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("working...");

            ClientFileService svc = new ClientFileService(@"I:\Work\MyBizApp\ExcelWorkLogTool\TestData\散客\[对数表]散客A.xlsx");

            var data = new BillSales[] {
                new BillSales{  LoadingFee=0m, Note="备注1", ProductAmount=1m, ProductName="服务费1", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m },
                new BillSales{  LoadingFee=0m, Note="备注2", ProductAmount=1m, ProductName="服务费2", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m },
                new BillSales{  LoadingFee=0m, Note="备注3", ProductAmount=1m, ProductName="服务费3", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m },
                new BillSales{  LoadingFee=0m, Note="备注4", ProductAmount=1m, ProductName="服务费4", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m },
                new BillSales{  LoadingFee=0m, Note="备注5", ProductAmount=1m, ProductName="服务费5", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m },
                new BillSales{  LoadingFee=0m, Note="备注6", ProductAmount=1m, ProductName="服务费6", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m },
                new BillSales{  LoadingFee=0m, Note="备注7", ProductAmount=1m, ProductName="服务费7", ProductPrice=1m, ProductUnit="宗", SalesDate=DateTime.Today, ShippingFee=0m,  TotalMoney=1m }
            };

            svc.Save(data, "材料");

            //QueryWorkLogItemsTest();

            Console.WriteLine("done...");
            Console.ReadLine();
        }

        private static void QueryWorkLogItemsTest()
        {
            string f = @"D:\Work\档口资料\MyBizApp\ExcelWorkLogTool\TestData\日记_201801.xlsx";
            ExcelWorkLogService logSvc = new ExcelWorkLogService(f);
            var logs = logSvc.QueryWorkLogItems(new string[] { "1-31" }, null);

            var peopleSvc = new CrmPeopleService(AppConfig.DBConnectionString);
            var bills = ClientFileService.ConvertToBillSales(logs, peopleSvc, true);

            foreach (var b in bills)
            {
                Console.Write("" + b.SalesDate);
                Console.Write("\t" + b.BillType);
                Console.Write("\t" + b.ClientName);
                Console.Write("\t" + b.ProductName);
                Console.Write("\t" + b.ProductUnit);
                Console.Write("\t" + b.ProductAmount);
                Console.Write("\t" + b.ProductPrice);
                Console.Write("\t" + b.ShippingFee);
                Console.Write("\t" + b.TotalMoney);
                Console.Write("\t" + b.ShippingMethod);
                Console.Write("\t" + b.Note);
                Console.Write("\t" + b.ShippingAddress);

                Console.WriteLine();
            }
        }
    }
}
